#ifndef MEDIAN2_H
#define MEDIAN2_H

template <typename T> 
T median2(T* X, T* Y, int size) 
{ 
    int m = (size - 1) / 2; 


    if (X[m] == Y[m]) 
        return X[m]; 
    else if (X[m] > Y[m]) 
        return size == 1 ? Y[m] : median2 (X, Y + size - m - 1, m + 1); 
    else 
        return size == 1 ? X[m] : median2 (X + size - m - 1, Y, m + 1); 
}

#endif